﻿<?xml version="1.0" encoding="utf-8" ?>
<DataSource>
  <Description>Order Database</Description>
  <Parameters>
    <Parameter>
      <Name>@Date</Name>
      <Value>$$DATE.TODAY</Value>
    </Parameter>
    <Parameter Name="@Count"/>
  </Parameters>
  <ExecutionSteps>
    <Step Name="GetOrderHeaders" Type="Query">
      <InputParameters>
        <Parameter Name="@Date"/>
      </InputParameters>
      <Statement Type="SQL">
        <![CDATA[
        SELECT * FROM OrderHeader WHERE 
        OrderDate = @Date AND Processed = false 
        ]]>
      </Statement>
      <Output>
        <DataTable Name="OrderHeader">
          <Field>OrderId</Field>
          <Field>Customer</Field>
          <Field>Location</Field>
        </DataTable>
      </Output>
    </Step>
    <Step Name="Evaluate" Type="Evaluate">
      <Set>
        <Parameter Name="@Count">$GetOrders.OrderHeader.Count</Parameter>
      </Set>
    </Step>
    <Step Name="CheckOrders" Type="Condition">
      <InputParameters>
        <Parameter Name="@Count"/>
      </InputParameters>
    </Step>
    <Statement>
      <If>
        <Condition Parameter="@Count" Operand=">">1</Condition>
      </If>
    </Statement>
    
  </ExecutionSteps>
</DataSource>